package com.zb.zbtpd.controller;

import com.zb.zbtpd.feignclient.NewsTypeFeignClient;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.redis.core.StringRedisTemplate;
import org.springframework.stereotype.Controller;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
@Controller
@RequestMapping("/zbt/pd/newstype")
public class NewsTypeController {

    /**
     * 智伯商学院类型
     */
    @Autowired
    private NewsTypeFeignClient newsTypeFeignClient;
    @Autowired
    private StringRedisTemplate stringRedisTemplate;

    @RequestMapping("/listNewsType")
    @ResponseBody
    public String listNewsType(){
        String newsTypeList=stringRedisTemplate.opsForValue().get("newsTypeList");
        if (StringUtils.isEmpty(newsTypeList)){
            newsTypeList = newsTypeFeignClient.findNewsType();
            stringRedisTemplate.opsForValue().set("newsTypeList",newsTypeList);
        }
        return newsTypeList;
    }

    /**
     * 智伯咨询分类
     * @return
     */
    @RequestMapping("/findNewsTypeZixun")
    @ResponseBody
    public String findNewsTypeZixun(){
        String newsTypeZixun=stringRedisTemplate.opsForValue().get("newsTypeZixun");
        if (StringUtils.isEmpty(newsTypeZixun)){
            newsTypeZixun=newsTypeFeignClient.findNewsTypeZixun();
            stringRedisTemplate.opsForValue().set("newsTypeZixun",newsTypeZixun);
        }
        return newsTypeZixun;
    }


}
